package com.niit.service.impl;

import java.util.List;

import com.niit.bean.BlogReply;
import com.niit.dao.BlogReplyDao;
import com.niit.dao.impl.BlogReplyDaoImpl;
import com.niit.service.BlogReplyService;
import com.niit.utils.Page;

public class BlogReplyServiceImpl implements BlogReplyService {
	
	private BlogReplyDao dao = new BlogReplyDaoImpl();
	
	@Override
	public int add(BlogReply t) {
		return dao.add(t);
	}

	@Override
	public int delete(BlogReply t) {
		return dao.delete(t);
	}

	@Override
	public int update(BlogReply t) {
		return dao.update(t);
	}

	@Override
	public Page<BlogReply> getPage(String pagenum, String url) {
		int total = dao.findTotal();
		Page<BlogReply> page = null;
		if(pagenum == null){
			page = new Page<BlogReply>(total,1);
		}else{
			page = new Page<BlogReply>(total, Integer.parseInt(pagenum));
		}
		List<BlogReply> list = dao.findAll(page.getStartIndex(), page.getEndIndex());
		page.setList(list);
		page.setUrl(url);
		return page;
	}

}
